home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions BackLaguerreAxon component
-
- #include "NSDLL.h"
-
- /********************************/
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackGammaAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- DLLData *dualInstance, // Pointer to the forward axons instance data (may be NULL)
- NSFloat *error, // Pointer to the current error vector
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *delayedError, // Pointer to the error vector delayed by a user defined time step
- int taps, // Number of memory taps specified by the user in the inspector
- NSFloat *data, // Pointer to the layers of processing elements (PEs)
- NSFloat *gamma, // Pointer to a vector of gamma coefficients, one for each PE
- NSFloat *gradient // Pointer to the gamma gradient vector
- )
- {
- register int i,j,k,length=rows*cols;
- NSFloat gain;
-
- for (i=0; i<length; i++) {
- gain = (NSFloat)pow(1-pow(gamma[i], 2.0f), 0.5f);
- for (j=taps-1; j>=0; j--) {
- k = i + j*length;
- if (j==0) {
- error[k] += gamma[i]*delayedError[k]/gain;
- error[k] *= gain;
- if (gradient)
- gradient[i] += data[k]*delayedError[k]/gain;
- }
- else {
- error[k] += gamma[i]*delayedError[k];
- error[k-length] += delayedError[k] - gamma[i]*error[k];
- if (gradient)
- gradient[i] += delayedError[k]*data[k] - error[k]*data[k-length];
- }
- }
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocBackGammaAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- int taps // Number of taps attached to each PE
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeBackGammaAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */
-